<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>融资筛选列表</title>
<style type="text/css">
    .searchArea .fieldBox .label{width: 80px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
    .layout2col1 .fieldBox .label{width: 80px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
    .replacement_record{font-size: 16px;line-height: 28px;color: #00877a;font-family: "微软雅黑", "宋体", Arial, sans-serif;} 
</style>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
	<div class="searchArea">
		<form id="assPackInfoReplace_form">
         <div class="fieldset1 clearFix">
          	<div class="fieldBox">
                <div class="label">融资基数</div>
                <div class="field">
                <input name="fncCrdnltNm3" id="fncCrdnltNm" type="text" class="ui-textbox" value="${assPackInfo.fncCrdnltNm}" disabled="disabled" ligerui="width: 182">
                <input name="fncCrdnlt" id="fncCrdnlt" type="hidden" class="ui-textbox" data-name="fncCrdnlt" value="${assPackInfo.fncCrdnlt}" ligerui="width: 182">
                <input name="stdt" id="stdt" type="hidden" class="ui-textbox" data-name="stdt" value="${assPackInfo.planStdt}" ligerui="width: 182">
                <input name="eddt" id="eddt" type="hidden" class="ui-textbox" data-name="eddt" value="${assPackInfo.planEddt}" ligerui="width: 182">
                <input name="fncInsIdQ" id="fncInsIdQ" type="hidden" class="ui-textbox" data-name="fncInsIdQ" value="${assPackInfo.id}" ligerui="width: 182">
                <input name="repSt" id="repSt" type="hidden" class="ui-textbox" data-name="repSt" value="${assPackInfo.repSt}" ligerui="width: 182">
                <input name="mainId" id="mainId" type="hidden" class="ui-textbox" data-name="mainId" value="${mainId}" ligerui="width: 182">
                </div>
            </div> 
            <div class="fieldBox">
                <div class="label">计划融资日期</div>
                <div class="field">
                <input name="stdt3" id="stdt3" type="text" class="ui-textbox" value="${assPackInfo.planStdt}" ligerui="width: 80" disabled="disabled">
                <span>—</span>
				<input name="eddt3" id="eddt3" type="text" class="ui-textbox" value="${assPackInfo.planEddt}" ligerui="width: 80" disabled="disabled">
                </div>
            </div>
			<div class="fieldBox">
                <div class="label">客户类型</div>
                <div class="field">
                <input name="cstTypCd3" id="cstTypCd3" type="text" class="ui-textbox" value="${assPackInfo.cstTypCdNm}" ligerui="width: 182" disabled="disabled">
                </div>
            </div>        
			<div class="fieldBox">
                <div class="label">所属事业部</div>
                <div class="field">
                <input name="buOrgCd3" id="buOrgCd3" type="text" class="ui-textbox" value="${assPackInfo.buOrgCdNm}" ligerui="width: 182" disabled="disabled">
                </div>
            </div>        
			<div class="fieldBox">
                <div class="label">是否办理抵押</div>
                <div class="field">
                <input name="isMortgage3" id="isMortgage3" type="text" class="ui-textbox" value="${assPackInfo.isMgtNm}" ligerui="width: 182" disabled="disabled">
                </div>
            </div>        
			<div class="fieldBox">
                <div class="label">是否有保险</div>
                <div class="field">
                <input name="isInsurance3" id="isInsurance3" type="text" class="ui-textbox" value="${assPackInfo.isInsureNm}" ligerui="width: 182" disabled="disabled">
                </div>
            </div>        
            <div class="fieldBox">
                <div class="label">租赁期数</div>
                <div class="field">
                   <input name="leaseTermMinQ3" id="leaseTermMinQ3" type="text" class="ui-textbox" value="${assPackInfo.leaTermB}" ligerui="width: 80" disabled="disabled">
                   <span>—</span>
                   <input name="leaseTermMaxQ3" id="leaseTermMaxQ3" type="text" class="ui-textbox" value="${assPackInfo.leaTermE}" ligerui="width: 80" disabled="disabled">
                </div>
            </div>
            <div class="fieldBox">
                <div class="label">剩余租赁期数</div>
                <div class="field">
                   <input name="surplusLeaseTermMinQ3" id="surplusLeaseTermMinQ3" type="text" class="ui-textbox" value="${assPackInfo.reLeaTermB}" ligerui="width: 80" disabled="disabled">
                   <span>—</span>
                   <input name="surplusLeaseTermMaxQ3" id="surplusLeaseTermMaxQ3" type="text" data-name="surplusLeaseTermMaxQ" class="ui-textbox" value="${assPackInfo.reLeaTermE}" ligerui="width: 80" disabled="disabled">
                </div>
            </div>
            <div class="fieldBox">
                <div class="label">起租日期</div>
                <div class="field">
                   <input name="stDtQ3" id="stDtQ3" type="text" class="ui-textbox" value="${assPackInfo.flDateBegin}" ligerui="width: 80" disabled="disabled">
                   <span>—</span>
                   <input name="edDtQ3" id="edDtQ3" type="text" class="ui-textbox" value="${assPackInfo.flDateEnd}" ligerui="width: 80" disabled="disabled">
                </div>
            </div>
            <div class="fieldBox">
                <div class="label">逾期天数</div>
                <div class="field">
                   <input name="ovdDaysMin3" id="ovdDaysMin3" type="text" class="ui-textbox" value="${assPackInfo.odDateB}" ligerui="width: 80" disabled="disabled">
                   <span>—</span>
                   <input name="ovdDaysMax3" id="ovdDaysMax3" type="text" class="ui-textbox" value="${assPackInfo.odDateE}" ligerui="width: 80" disabled="disabled"> 
                </div>
             </div>
             <div class="clearFix"></div>
             <div class="formBtns notRight">
                  <span id="replaceBtn" class="sq-button-round" onclick="saveAndStartFlow();">替换资产</span>
			</div>
         </div>
    	</form>
    </div>
    <table class="layout2col1" style="height:590px;">
        <tbody>
        	<tr>
        		<td style="width: 500px;" valign="top">
        			<div  class="sqPanel">
                        <div class="sqPanel_head">
                        	<div class="label">资产包支付表</div>
                        </div>
                    </div>
        		</td>
        		<td style="width: 400px;" valign="top">
        			<div class="sqPanel">
                        <div class="sqPanel_head">
                        	<div class="label">可替换支付表</div>
                        </div>
                    </div>
        		</td>
        	</tr>
            <tr>
                <td style="width: 50%;" valign="top">
                <div class="sqPanel">
                    <div class="">
                        <div class="searchArea">
                            <form id="searchBar1">
                                <div class="fieldset1 clearFix">
                                    <div class="fieldBox">
                                        <div class="label">客户名称</div>
                                        <div class="field">
                                             <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="" ligerui="width: 140">
                                        </div>
                                    </div>
                                    <div class="fieldBox">
                                        <div class="label">支付表编号</div>
                                        <div class="field">
                                             <input name="paySchId" id="paySchId" type="text" class="ui-textbox" value="" ligerui="width: 140">
                                        </div>
                                    </div>
                                   <%--  <div class="fieldBox">
                                        <div class="label">是否齐全</div>
                                        <div class="field">
                                        	<select name="crCd" id="crCd" data-value=" " ligerui="width: 140">
						                    	<option value=" " selected="selected">请选择</option>
						                         <c:forEach items="${cstTypCdList }" var="ct">
						                     		<option value="${ct.key }">${ct.value }</option>
						                        </c:forEach>
						                    </select>
                                        </div>
                                    </div> --%>
                                    <%-- <div class="fieldBox">
                                        <div class="label">提取状态</div>
                                        <div class="field">
                                        	<select name="extractionCd" id="extractionCd" data-value=" " ligerui="width: 140">
						                    	<option value=" " selected="selected">请选择</option>
						                         <c:forEach items="${cstTypCdList }" var="ct">
						                     		<option value="${ct.key }">${ct.value }</option>
						                        </c:forEach>
						                    </select>
                                        </div>
                                    </div> --%>
                                    <div class="fieldBox">
                                        <div class="label">事业部</div>
                                        <div class="field">
                                        <input name="buOrgCd" id="buOrgCd" type="text" class="ui-textbox" data-value=" " placeholder="--请选择--" ltype="combobox" value="" ligerui="width: 140">
                                        	<%-- <select name="buOrgCd" id="buOrgCd" data-value=" " ligerui="width: 140">
						                    	<option value=" " selected="selected">请选择</option>
						                         <c:forEach items="${buOrgCdList }" var="bo">
						                     		<option value="${bo.key }">${bo.value }</option>
						                        </c:forEach>
						                    </select> --%>
                                        </div>
                                    </div>
                                    <div class="fieldBox">
                                        <div class="label">逾期天数</div>
                                        <div class="field">
                                        	<input name="ovdDaysMin" id="ovdDaysMin" type="text" ligerui="width: 60" class="ui-textbox" value="" validate="{digits:true}">
						                    <span style="line-height: 20px;">—</span>
						                    <input name="ovdDaysMax" id="ovdDaysMax" type="text" ligerui="width: 60" class="ui-textbox" value="" validate="{digits:true}">
                                        </div>
                                    </div>
                                    <div class="fieldBox">
						                <div class="label">勾选金额</div>
						                <div class="field">
						                   <span id="isFinancingAmount" style="width: 140px;float: left;line-height: 20px;">0.00</span>
						                </div>
						            </div>
						           <div class="fieldBox">
						                <div class="label">已选数量</div>
						                	<div class="field">
						                    <span id="selectedCount" style="width: 100px;float: left;line-height: 20px;">0</span>
						           			</div>
						            </div>
                                    <div class="clearFix"></div>
									<div class="formBtns notRight">
	                                    <span id="searchBtn1" class="sq-button-round">查询</span>
	                                    <span id="clearBtn1" class="sq-button-round">清空</span>
									</div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                </td>
                <td style="width: 50%;" valign="top">
                <div class="sqPanel">
                    <div class="">
                        <div class="searchArea">
                            <form id="searchBar2">
                                <div class="fieldset1 clearFix">
                                    <div class="fieldBox">
                                        <div class="label">客户名称</div>
                                        <div class="field">
                                             <input name="cstNm2" id="cstNm2" type="text" class="ui-textbox" value="" ligerui="width: 140">
                                        </div>
                                    </div>
                                    <div class="fieldBox">
                                        <div class="label">支付表编号</div>
                                        <div class="field">
                                             <input name="paySchId2" id="paySchId2" type="text" class="ui-textbox" value="" ligerui="width: 140">
                                        </div>
                                    </div>
                                    <%-- <div class="fieldBox">
                                        <div class="label">是否齐全</div>
                                        <div class="field">
                                        	<select name="crCd2" id="crCd2" data-value=" " ligerui="width: 140">
						                    	<option value=" " selected="selected">请选择</option>
						                         <c:forEach items="${cstTypCdList }" var="ct">
						                     		<option value="${ct.key }">${ct.value }</option>
						                        </c:forEach>
						                    </select>
                                        </div>
                                    </div> --%>
                                    <div class="fieldBox">
                                        <div class="label">事业部</div>
                                        <div class="field">
                                        <input name="buOrgCd2" id="buOrgCd2" type="text" class="ui-textbox" data-value=" " placeholder="--请选择--" ltype="combobox" value="" ligerui="width: 140">
                                        	<%-- <select name="buOrgCd2" id="buOrgCd2" data-value=" " ligerui="width: 140">
						                    	<option value=" " selected="selected">请选择</option>
						                         <c:forEach items="${buOrgCdList }" var="bo">
						                     		<option value="${bo.key }">${bo.value }</option>
						                        </c:forEach>
						                    </select> --%>
                                        </div>
                                    </div>
                                    <div class="fieldBox">
                                        <div class="label">逾期天数</div>
                                        <div class="field">
                                        	<input name="ovdDaysMin2" id="ovdDaysMin2" type="text" ligerui="width: 60" class="ui-textbox" value="" validate="{digits:true}">
						                    —
						                    <input name="ovdDaysMax2" id="ovdDaysMax2" type="text" ligerui="width: 60" class="ui-textbox" value="" validate="{digits:true}">
                                        </div>
                                    </div>
                                    <div class="fieldBox">
						                <div class="label">可融资金额</div>
						                <div class="field">
						                   <span id="isFinancingAmount2" style="width: 140px;float: left;">0.00</span>
						                </div>
						            </div>
						           <div class="fieldBox">
						                <div class="label">已选数量</div>
					                	<div class="field">
					                    	<span id="selectedCount2" style="width: 100px;float: left;line-height: 20px;">0</span>
					           			</div>
						            </div>
                                    <div class="clearFix"></div>
									<div class="formBtns notRight">
	                                    <span id="searchBtn2" class="sq-button-round">查询</span>
	                                    <span id="clearBtn2" class="sq-button-round">清空</span>
									</div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                </td>
            </tr>
            <tr>
            	<td>
            		<div id="ligergrid1" class="sq-grid" style="height: 400px;"></div>
            	</td>
            	<td>
            		<div id="ligergrid2" class="sq-grid" style="height: 400px;"></div>
            	</td>
            </tr>
        </tbody>
    </table>
</div>
	<div class="replacement_record">资产替换记录</div>
	<div id="ligergridRecord" class="sq-grid" style="height: 172px;"></div>


<script type="text/javascript">
	var grid = null;
	var grid2 = null;
	var checkedCustomer = [];
    var termB = [];
    var termE = [];
    var financingAmount = [];
    var isFinancingAmount = 0.00;
	var checkedCustomer2 = [];
    var termB2 = [];
    var termE2 = [];
    var financingAmount2 = [];
    var isFinancingAmount2 = 0.00;
	var fncInsIdQ = $("#fncInsIdQ").val();
	var fncCrdnlt = $("#fncCrdnlt").val();
	var stdt = $("#stdt").val();
	var eddt = $("#eddt").val();
	$(function () {
		initbuOrgCd();
		initbuOrgCd2();
		assPackInfoInitList();
		replaceAssPackInfoInitList();
	});
	
	//所属事业部
	function initbuOrgCd(){
		$("#buOrgCd").ligerComboBox({ 
			url: '<%=path%>/ass/asspackinfo/getbuOrgCd.do',
			ajaxType :'GET',
            slide: false,
            selectBoxHeight: 200,
            valueField: 'key', 
            textField: 'value',
            isMultiSelect: true
        });
	}
	
	//所属事业部
	function initbuOrgCd2(){
		$("#buOrgCd2").ligerComboBox({ 
			url: '<%=path%>/ass/asspackinfo/getbuOrgCd.do',
			ajaxType :'GET',
            slide: false,
            selectBoxHeight: 200,
            valueField: 'key', 
            textField: 'value',
            isMultiSelect: true
        });
	}
	
	function assPackInfoInitList(){
		$("#assPackInfoReplace_form").ligerForm({validate: true});
		$("#searchBar1").ligerForm({validate: true});
		var _url1 = '<%=path%>/ass/asspackinfo/assPackInfoInitList.do';
    	$("#ligergrid1").ligerGrid({
    		url : _url1,
    		method : 'get',
    		parms : {"fncInsIdQ":fncInsIdQ,"fncCrdnlt":fncCrdnlt,"stdt":stdt,"eddt":eddt,"isEdit":"1"},
        	columns: [
	            { display: '再融资状态', name: 'financingTypeNm', width: 90},
	            { display: '客户名称', name: 'cstNm', width: 140 },
	            { display: '事业部', name: 'buOrgNm', width: 140 },
	            { display: '支付表编号', name: 'paySchId', width: 180 },
	            { display: '可融资金额', name: 'financingAmount', width: 100 }
	        ],
	        pageSize:10,
	        pageSizeOptions: [10,20,30,50,100,500,1000],
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'78%',
	        heightDiff:-2,
	        checkbox:true,
	        rownumbers:true,
	        isChecked: f_isChecked, 
	        onCheckRow: f_onCheckRow, 
	        onCheckAllRow: f_onCheckAllRow

    	});
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	    $("#searchBar1").ligerForm();
	 }
	    
	$("#searchBtn1").click(function(event) {
	    var form = new liger.get("searchBar1");
		if (!form.valid()) {
			top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
			return false; //验证不通过，不执行以下代码
		}
	    var data = form.getData();
	    for (var name in data){
	       grid.setParm(name,data[name]);
	    };
	   $("#selectedCount").html('0');
       $("#isFinancingAmount").html('0.00');
       isFinancingAmount = 0.00;
       checkedCustomer.splice(0,checkedCustomer.length);
       termB.splice(0,termB.length);
       termE.splice(0,termE.length);
       financingAmount.splice(0,financingAmount.length);
	   grid.reload();
	});
		
	 /* 清空 */
     $("#clearBtn1").click(function (event) {
         clearLigerForm("searchBar1");
     });
		 
     /* 查询2 */
     function replaceAssPackInfoInitList(){
        $("#searchBar2").ligerForm({validate: true});
		var _url2 = '<%=path%>/ass/asspackinfo/replaceAssPackInfoInitList.do';
    	$("#ligergrid2").ligerGrid({
    		url : _url2,
    		method : 'get',
    		parms : {"fncInsIdQ":fncInsIdQ,"fncCrdnlt":fncCrdnlt,"stdt":stdt,"eddt":eddt,"isEdit":"0"},
        	columns: [
	            { display: '再融资状态', name: 'financingTypeNm', width: 90},
	            { display: '客户名称', name: 'cstNm', width: 140 },
	            { display: '事业部', name: 'buOrgNm', width: 140 },
	            { display: '支付表编号', name: 'paySchId', width: 180 },
	            { display: '可融资金额', name: 'financingAmount', width: 100 }
	        ],
	        pageSize:10, 
	        pageSizeOptions: [10,20,30,50,100,500,1000],
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'78%',
	        heightDiff:-2,
	        checkbox:true,
	        rownumbers:true,
	        isChecked: f_isChecked2, 
	        onCheckRow: f_onCheckRow2, 
	        onCheckAllRow: f_onCheckAllRow2

    	});
	    grid2 = liger.get("ligergrid2");
	    grid2.setHeight(100);
	    $("#searchBar2").ligerForm();
     }
     
	$("#searchBtn2").click(function(event) {
	    var form2 = new liger.get("searchBar2");
		if (!form2.valid()) {
			top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
			return false; //验证不通过，不执行以下代码
		}
	    var data2 = form2.getData();
	    for (var name in data2){
	       grid2.setParm(name,data2[name]);
	    };
	   $("#selectedCount2").html('0');
       $("#isFinancingAmount2").html('0.00');
       isFinancingAmount2 = 0.00;
       checkedCustomer2.splice(0,checkedCustomer2.length);
       termB2.splice(0,termB2.length);
       termE2.splice(0,termE2.length);
       financingAmount2.splice(0,financingAmount2.length);
	   grid2.reload();
	});
        
    /* 清空 */
    $("#clearBtn2").click(function (event) {
        clearLigerForm("searchBar2");
    });
		
    //资产替换记录
   	var _url3 = '<%=path%>/ass/asspackinfo/recordReplaceAssPackInfoInitList.do';
   	$("#ligergridRecord").ligerGrid({
   		url : _url3,
   		method : 'get',
   		parms : {"fncInsIdQ":fncInsIdQ},
       	columns: [
            { display: '替换状态', name: 'repTypeNm', width: 90},
            { display: '操作时间', name: 'operationDate', width: 90, render:renderDate},
            { display: '原还款表', name: 'oldPayId', width: 300 },
            { display: '融资金额', name: 'financingAmount', width: 140 },
            { display: '替换还款表', name: 'replacePayId', width: 300 },
            { display: '替换融资金额', name: 'replaceFinancingAmount', width: 90},
            { display: '操作人', name: 'crtPsnEcd', width: 100 }
        ],
        pageSize:10, 
        root:'rows',
        record:'total',
        hideLoadButton : true,
        width: '100%',
        height:'100%',
        heightDiff:-2
   	});
	
	
	function f_onCheckAllRow(checked){
        for (var rowid in this.records){
            if(checked)
                addCheckedCustomer(this.records[rowid]);
            else
                removeCheckedCustomer(this.records[rowid]);
        }
    }

    /*
    该例子实现 表单分页多选
    即利用onCheckRow将选中的行记忆下来，并利用isChecked将记忆下来的行初始化选中
    */
    function findCheckedCustomer(CustomerID){
        for(var i =0;i<checkedCustomer.length;i++){
            if(checkedCustomer[i] == CustomerID) return i;
        }
        return -1;
    }
    function addCheckedCustomer(data){
        if(findCheckedCustomer(data.id) == -1){
            checkedCustomer.push(data.id);
        	termB.push(data.minPd);
        	termE.push(data.maxPd);
        	financingAmount.push(data.financingAmount);
        	isFinancingAmount = parseFloat(isFinancingAmount + data.financingAmount);
        	$("#selectedCount").html(checkedCustomer.length);
        	$("#isFinancingAmount").html(isFinancingAmount.toFixed(2));
        }
    }
    function removeCheckedCustomer(data){
        var i = findCheckedCustomer(data.id);
        if(i==-1) return;
        checkedCustomer.splice(i,1);
        termB.splice(i,1);
    	termE.splice(i,1);
    	financingAmount.splice(i,1);
    	isFinancingAmount = parseFloat(isFinancingAmount - data.financingAmount);
    	$("#selectedCount").html(checkedCustomer.length);
    	if(isFinancingAmount < 0){
    		isFinancingAmount = 0.00;
    	}
    	$("#isFinancingAmount").html(isFinancingAmount.toFixed(2));
    }
    function f_isChecked(rowdata){
        if (findCheckedCustomer(rowdata.id) == -1)
            return false;
        return true;
    }
    function f_onCheckRow(checked, data){
        //if (checked) addCheckedCustomer(data.id,data.minPd,data.maxPd);
        if (checked) addCheckedCustomer(data);
        else removeCheckedCustomer(data);
    }
    
    
    //可替换支付表复选框方法
	function f_onCheckAllRow2(checked){
        for (var rowid in this.records){
            if(checked)
                addCheckedCustomer2(this.records[rowid]);
            else
                removeCheckedCustomer2(this.records[rowid]);
        }
    }

    /*
    该例子实现 表单分页多选
    即利用onCheckRow将选中的行记忆下来，并利用isChecked将记忆下来的行初始化选中
    */
    function findCheckedCustomer2(CustomerID){
        for(var i =0;i<checkedCustomer2.length;i++){
            if(checkedCustomer2[i] == CustomerID) return i;
        }
        return -1;
    }
    function addCheckedCustomer2(data){
        if(findCheckedCustomer2(data.id) == -1){
            checkedCustomer2.push(data.id);
        	termB2.push(data.minPd);
        	termE2.push(data.maxPd);
        	financingAmount2.push(data.financingAmount);
        	isFinancingAmount2 = parseFloat(isFinancingAmount2 + data.financingAmount);
        	$("#selectedCount2").html(checkedCustomer2.length);
        	$("#isFinancingAmount2").html(isFinancingAmount2.toFixed(2));
        }
    }
    function removeCheckedCustomer2(data){
        var i = findCheckedCustomer2(data.id);
        if(i==-1) return;
        checkedCustomer2.splice(i,1);
        termB2.splice(i,1);
    	termE2.splice(i,1);
    	financingAmount2.splice(i,1);
    	isFinancingAmount2 = parseFloat(isFinancingAmount2 - data.financingAmount);
    	$("#selectedCount2").html(checkedCustomer2.length);
    	if(isFinancingAmount2 < 0){
    		isFinancingAmount2 = 0.00;
    	}
    	$("#isFinancingAmount2").html(isFinancingAmount2.toFixed(2));
    }
    function f_isChecked2(rowdata){
        if (findCheckedCustomer2(rowdata.id) == -1)
            return false;
        return true;
    }
    function f_onCheckRow2(checked, data){
        //if (checked) addCheckedCustomer(data.id,data.minPd,data.maxPd);
        if (checked) addCheckedCustomer2(data);
        else removeCheckedCustomer2(data);
    }
    
    //替换保存
    function saveAndStartFlow(){
    	if(checkedCustomer.join(',') != '' || checkedCustomer2.join(',') != ''){
			var repSt = $("#repSt").val();
			if(repSt == "0"){
				startFlow();
			}else{
				add();
			}
		}else{
			top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW , SQ_type: "warning" });
	    	return false; //验证不通过，不执行以下代码
		}
    }
	
	 //新增数据
	function add(){
		var _payRltvInfo = checkedCustomer.join(',');
		var _termB = termB.join(',');
		var _termE = termE.join(',');
		var _financingAmount = financingAmount.join(',');
		var _payRltvInfo2 = checkedCustomer2.join(',');
		var _termB2 = termB2.join(',');
		var _termE2 = termE2.join(',');
		var mainId = $("#mainId").val();
		var _financingAmount2 = financingAmount2.join(',');
		var _data = {"payRltvInfo" : _payRltvInfo, "termB": _termB, "termE" : _termE, "financingAmount" : _financingAmount
				, "fncInsIdQ" : fncInsIdQ, "payRltvInfo2" : _payRltvInfo2, "termB2" : _termB2, "termE2" : _termE2
				, "financingAmount2" : _financingAmount2, "mainId" : mainId};
		var _url = '<%=path%>/ass/asspackinfo/modifyReplaceAssPackInfo.do';
		//发送异步请求校验
		var wait_dialog;
		$.ajax({
			type: 'post',
			dataType: 'json',
			data: _data,
			url: _url,
			beforeSend: function(){
		          wait_dialog=top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			},
			success:function(msg){
				 wait_dialog.close();
				 if(msg.success == 1){
					top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
				 }else if(msg.success == 0 && !msg.data){//校验不成功,且没有data(id)报错
					top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					frameElement.dialog.close();
				 }
			}
		});
	}
	 
	//启动流程
	function startFlow(_data){
		var modelTyp ="R008";//流程业务分类-再融资资产替换审核
        var flowDialog = $.ligerDialog.SQopen({
            url: '<%=path%>/flow/flow/toForStartListPage.do?modelTyp='+modelTyp,
            width: 700,
            height:400,
            title : '请选择要发起的流程',
            buttons: [{
	                text: "确定", type: 'ok', cls: 'l-dialog-btn-ok',
	                onclick: function (item, Dialog) {
	                    if (Dialog.onOk) Dialog.onOk();
	                }
	            }, {
	                text: "取消", type: 'cancel', cls: 'l-dialog-btn-no',
	                onclick: function (item, Dialog) {
	                    if (Dialog.onCancel) Dialog.onCancel();
	                }
	            }
	        ],
            onClose: function () {
            	var json = flowDialog._DATA;
            	console.log(json);
            	if(!json){
                	return;
            	}
            	var _payRltvInfo = checkedCustomer.join(',');
    			var _termB = termB.join(',');
    			var _termE = termE.join(',');
    			var _financingAmount = financingAmount.join(',');
    			var _payRltvInfo2 = checkedCustomer2.join(',');
    			var _termB2 = termB2.join(',');
    			var _termE2 = termE2.join(',');
    			var _financingAmount2 = financingAmount2.join(',');
    			var _data = {"payRltvInfo" : _payRltvInfo, "termB": _termB, "termE" : _termE, "financingAmount" : _financingAmount
    					, "fncInsIdQ" : fncInsIdQ, "payRltvInfo2" : _payRltvInfo2, "termB2" : _termB2, "termE2" : _termE2
    					, "financingAmount2" : _financingAmount2};
            	var wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting",onClose: function () {}});
        		$.ajax({
            		type: 'post',
            		dataType:'json',
            		data:_data,
            		url: '<%=path%>/ass/asspackinfo/addReplaceAssPackInfo.do',
					success : function(msg) {
						//wait_dialog.close();
						if (msg.success == 1 && msg.id != 0) {
			    			var _data2 = {"replaceId" : msg.id, "procDefKey":json.procDefKey,"procDefId":json.procDefId,"procNo":json.procNo};
							$.ajax({
			            		type: 'post',
			            		dataType:'json',
			            		data:_data2,
			            		url: '<%=path%>/ass/asspackinfo/addFlowStart.do',
								success : function(msg) {
									wait_dialog.close();
									if (msg.success == 1) {
										UIUtils.alertSuccessHold2(msg.info);
									} else {
										UIUtils.alertErrorHold1(msg.info);
									}
								}
							});
						} else {
							UIUtils.alertErrorHold1(msg.info);
						}
					}
				});
			}
		});
	}
	 
	<%-- function seeDetail(){
		 var assPackId=$("#fncInsIdQ").val();
		 Add_navTab('replaceAssPackInfo_1','详情','<%=path%>/ass/asspackinfo/replaceAssPackToExamine.do?assPackId='+assPackId);
	 } --%>
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
	
	//成功提示-有一个确定按钮 单击后关闭
	UIUtils.alertSuccessHold2 = function(msg){
		 $.ligerDialog.SQalert({content:msg, SQ_showButtons: true,SQ_type: "success",onClose: function () {
			 var selectedTabId = parent.mainApp.parentTab.selectedTabId;
			 var lastTab = parent.parent.tabItems[0];
			 parent.mainApp.parentTab.reload(lastTab.tabid);
			 parent.mainApp.parentTab.removeTabItem(selectedTabId);
			 //parent.parent.reloadAssPackInfoList();
		 }});
	}
	
	
</script>
</body>
</html>